﻿using System.Configuration;
using System.ServiceModel;
using QuailServices.QuailDataServiceReference;

namespace QuailServices
{
    /// <summary>
    /// Wraps construction of the QuailDataServiceClient object
    /// </summary>
    public static class QuailDataServiceFactory
    {
        /// <summary>
        /// Creates a new instance of the QuailDataServiceClient
        /// </summary>
        /// <returns>A new QuailDataServiceClient</returns>
        public static QuailDataServiceClient CreateClient()
        {
            var binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly);
            var host = ConfigurationManager.AppSettings["QuailDataService"] ?? "http://qaquailweb/QuailDataService.svc";

            var endpoint = new EndpointAddress(host);
            binding.MaxReceivedMessageSize = 2147483647;
            binding.MaxBufferSize = 2147483647;

            var result = new QuailDataServiceClient(binding, endpoint);

            return result;
        }
    }
}
